package com.hmy.finance.dal.po;


import com.baomidou.mybatisplus.annotation.*;
import com.hmy.finance.api.common.enums.RechargeTypeEnum;
import com.hmy.finance.dal.po.json.RelationBillInfoJsonArrayHandler;
import lombok.Data;
import org.apache.ibatis.type.EnumTypeHandler;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 余额回充业务单据
 *
 * @author kwaiiiii
 */
@Data
@TableName(value = "recharge_transaction_bill", autoResultMap = true)
public class RechargeTransactionBillPo implements Serializable {
    private static final long serialVersionUID = -7292036419724504725L;

    /**
     * 单据ID
     */
    @TableId(value = "bill_id", type = IdType.ASSIGN_ID)
    private Long billId;
    /**
     * 客户ID
     */
    @TableField(value = "customer_id")
    private Long customerId;
    /**
     * 合同ID
     */
    @TableField(value = "contract_id")
    private Long contractId;
    /**
     * 联系人ID
     */
    @TableField(value = "contactor_id")
    private Long contactorId;

    /**
     * 回充业务类型
     */
    @TableField(value = "recharge_type", typeHandler = EnumTypeHandler.class)
    private RechargeTypeEnum rechargeType;

    /**
     * 回充总金额
     */
    @TableField(value = "recharge_total_amount")
    private BigDecimal rechargeTotalAmount;
    /**
     * 回充明细信息
     */
    @TableField(value = "recharge_detail_info", typeHandler = RelationBillInfoJsonArrayHandler.class)
    private List<RelationBillInfo> rechargeDetailInfo;
    /**
     * 回充状态
     * 1-待处理，2-处理中，3-已完成，9-失败
     */
    @TableField(value = "recharge_status")
    private Integer rechargeStatus;

    @TableField(value = "is_deleted")
    @TableLogic
    private Integer isDeleted;

    @TableField(value = "create_time")
    private LocalDateTime createTime;

    @TableField(value = "creator_id")
    private Long creatorId;

    @TableField(value = "creator_name")
    private String creatorName;

    @TableField(value = "update_time")
    private LocalDateTime updateTime;

    @TableField(value = "updater_id")
    private Long updaterId;

    @TableField(value = "updater_name")
    private String updaterName;

    /**
     * 余额回充业务明细信息
     */
    @Data
    public static class RelationBillInfo implements Serializable {
        private static final long serialVersionUID = 3548837229887151090L;
        /**
         * 关联业务单据ID
         */
        private Long relationBillId;
        /**
         * 关联业务单据类型
         * 1-设备日流水,2-合同日流水
         */
        private Integer relationBillType;
        /**
         * 回充金额
         */
        private BigDecimal rechargeAmount;

    }
}
